// yasadll.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "yasadll.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "..\..\yasa\mmap.h"
#include "..\..\yasa\suffix.h"
extern FILE * debugfile;
#ifdef __cplusplus
}
#endif


#ifdef _MANAGED
#pragma managed(push, off)
#endif

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
    return TRUE;
}

#ifdef _MANAGED
#pragma managed(pop)
#endif

// This is an example of an exported variable
YASADLL_API int nyasadll=0;

// This is an example of an exported function.
YASADLL_API int getTF(const char *file_name, int uflag = 1, size_t max_length = 40, wchar_t **out_ptr = NULL)
{
	char *mmap_ptr = NULL;
    
	int len;
	int min_length = 1;
	debugfile = stderr;
	mmap_ptr = mmap_open_file(file_name);
    if (!mmap_ptr) return errno;
    len = strlen(mmap_ptr);
    int return_val = do_suffix(mmap_ptr, uflag, max_length, min_length, out_ptr);
    mmap_close (mmap_ptr, len);
    return return_val;
}
